import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_easyrefresh/easy_refresh.dart';

//刷新加载控件封装
class MyEasyRefresh extends StatelessWidget {
  late EasyRefreshController easyRefreshController;
  List<Widget> slivers;
  // ignore: use_key_in_widget_constructors
  MyEasyRefresh({required this.slivers}) {
    easyRefreshController = EasyRefreshController();
  }

  @override
  Widget build(BuildContext context) {
    return EasyRefresh.custom(
        controller: easyRefreshController,
        enableControlFinishRefresh: false,
        enableControlFinishLoad: false,
        header: ClassicalHeader(
            textColor: Colors.black87,
            refreshText: "往下拉，往下拉",
            refreshedText: "刷新完成",
            refreshingText: "正在刷新",
            refreshReadyText: "快放手"),
        footer: ClassicalFooter(
            textColor: Colors.black87,
            loadText: "往上拉，往上拉",
            loadedText: "我是底线",
            loadingText: "正在加载",
            loadReadyText: "快放手"),
        onRefresh: () async {
          print("刷新完成");
        },
        onLoad: () async {
          print("我是有底线的");
        },
        slivers: slivers);
  }
}
